/*-
 * Copyright (c) 2006 Vishal Patil <bsd.devil@gmail.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 */

#ifndef _ISCSI_LOGIN_PARAMS_H_
#define _ISCSI_LOGIN_PARAMS_H_

#include <stdbool.h>
#include "iscsi_session.h"
#include "iscsi_pdu.h"

#define ISCSI_LOGIN_ITT 0xffff5555
#define ISCSI_LOGOUT_ITT 0xffff4444

struct iscsi_login_params {
	int	port;
	int	tags;

	uint16_t	maxConnections;
	uint32_t	maxRecvDataSegmentLength;
	uint32_t	maxXmitDataSegmentLength;
	uint32_t	maxBurstLength;
	uint32_t	firstBurstLength;
	uint32_t	defaultTime2Wait;
	uint16_t	defaultTime2Retain;
	uint16_t	maxOutstandingR2T;
	uint8_t		errorRecoveryLevel;
	uint16_t	targetPortalGroupTag;

	uint8_t		initialR2T:1;
	uint8_t		immediateData:1;
	uint8_t		dataPDUInOrder:1;
	uint8_t		dataSequenceInOrder:1;

	char		*headerDigest;
	char		*dataDigest;
	char		*sessionType;
	char		*targetAddress;
	char		*targetAlias;
	char		*targetName;
	char		*initiatorName;
	char		*initiatorAlias;
	char		*authMethod;
	char		*chapSecret;
};

/*
 *	Extract the iSCSI login/op parameters from the iSCSI PDU
 */
int 
set_session_params(struct iscsi_session *,struct iscsi_pdu_incore *);

#endif
